#include <iostream>
#include <cstring>
#include <string>
using namespace std;
typedef struct Word{
	string s;
	int cnt;
}Word;
int main()
{
	Word word[100];
	int len=1;
	string str;
	word[0].cnt=1;
	while(cin>>str){
		bool isFind=false;
		for(int i=0;i<len;i++){
			if(word[i].s==str){
				word[i].cnt++;
				isFind=true;
				break;
			}
		}
		if(!isFind){
			len++;
			word[len-1].cnt=1;
			word[len-1].s=str;
		}
	}
	for(int i=0;i<len-1;i++){
		for(int j=0;j<len-i-1;j++){
			if(word[j].cnt<=word[j+1].cnt){
				Word temp=word[j];
				word[j]=word[j+1];
				word[j+1]=temp;
				if(word[j].cnt==word[j+1].cnt){
					if(word[j].s>word[j+1].s){
						Word temp=word[j];
						word[j]=word[j+1];
						word[j+1]=temp;
					}
				}
			}
		}
	}
	cout<<word[0].s<<' '<<word[0].cnt;
	return 0;
}
